package io;

import java.io.*;
/*
缓冲流：是一对高级流，作用是加快读写速度
缓冲流读写效率快的原因：内部有一个8KB的字节数组
 */
public class CopyDemo3Buffered {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("aaa.jpg");
        BufferedInputStream bis = new BufferedInputStream(fis);
        FileOutputStream fos = new FileOutputStream("aaa1.jpg");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        long start = System.currentTimeMillis();
        int d;
        while ((d=bis.read())!=-1){//使用缓冲流读取字节
            bos.write(d);//使用缓冲流写出字节
        }
        long end = System.currentTimeMillis();
        System.out.println("复制完毕！耗时"+(end-start)+"ms");
        bis.close();
        bos.close();
    }
}